// pages/my/my.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        people: [],
        year: [
            '2020', '2021', '2022'
        ],
        // year: 2022,
        oldyear: 2022,
        // yearset: 2020,
        // 偏移跳过几条
        skip: 0,
        student: [50],
        pageNumber: 0,
        // 查询几条
        take: 2,
        selectYear: ''
    },



    changeYear: function (e) {
        this.setData({
            selectYear: this.data.year[e.detail.value]
        })
    },

    queryStudent() {
        const { selectYear, skip, take } = this.data
        var that = this;
        wx.request({
            url: 'https://bangkeedu.com/api/outstandingStudents',
            data: {
                year: selectYear,
                skip: skip,
                take: take

            },
            method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
            // header: {}, // 设置请求的 header
            success: function (res) {
                //  console.log(res)
                // success
                if (res.statusCode == 200) {
                    that.setData({
                        // 将res.data保存在listDate方便我们去循环遍历
                        people: res.data[0],


                    })
                }
                // console.log(that.data.people)
                // console.log(that.data.people)

            },
            fail: function () {
                // fail
            },
            complete: function () {
                // complete
            }
        })
    },

  
   
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        const { year, skip, take } = this.data
        var that = this;
        wx.request({
            url: 'https://bangkeedu.com/api/outstandingStudents',
            data: {
                year: year,
                skip: skip,
                take: take

            },
            method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
            // header: {}, // 设置请求的 header
            success: function (res) {
                //  console.log(res)
                // success
                if (res.statusCode == 200) {
                    that.setData({
                        // 将res.data保存在listDate方便我们去循环遍历
                        people: res.data[0],


                    })
                }
                // console.log(that.data.people)

            },
            fail: function () {
                // fail
            },
            complete: function () {
                // complete
            }
        })

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {



    },
    onToOpinion: function (e) {
        wx.navigateTo({
            url: '',
        })
    },
    onToAbout: function (e) {
        wx.navigateTo({
            url: '',
        })
    }
})